import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Test {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource)dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setPassword("st730930");
        Connection connection = dataSource.getConnection();

        String sql = "insert into student value(104,'老六')";
        PreparedStatement preparedStatement =  connection.prepareStatement(sql);
        int ret = preparedStatement.executeUpdate();
        System.out.println("修改了"+ret+"条记录");

        preparedStatement.close();
        connection.close();


    }
}
